﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;

namespace Simple.Services;

public class QHSEOverLappingViolationModel : ModelBase
{
    /// <summary>
    /// 违章id
    /// </summary>
    [MaxLength(32)]
    [Key]
    public string? QhseXyViolationId { get; set; } = "";
    /// <summary>
    /// 检查类型
    /// </summary>
    [MaxLength(200)]
    public string Check_Type { get; set; } = "";
    /// <summary>
    /// 检查单位
    /// </summary>
    [MaxLength(200)]
    public string? CheckOrganizationId { get; set; } = "";
    /// <summary>
    /// 检查单位
    /// </summary>
    [MaxLength(200)]
    public string? CheckOrganizationName { get; set; } = "";

    /// <summary>
    /// 录入日期
    /// </summary>
    public DateTime? EnterTime { get; set; }

    /// <summary>
    /// 数据来源
    /// </summary>
    [MaxLength(100)]
    public string? EnterSys { get; set; }

    /// <summary>
    /// 检查人员ID
    /// </summary>
    [MaxLength(32)]
    public string UserId { get; set; } = "";
    /// <summary>
    /// 检查人员姓名
    /// </summary>
    [MaxLength(255)]
    public string UserName { get; set; } = "";
    /// <summary>
    /// 检查日期
    /// </summary>
    public DateTime CheckDate { get; set; }

    /// <summary>
    /// 被检单位ID
    /// </summary>
    [MaxLength(255)]
    public string OrganizationId { get; set; } = "";

    /// <summary>
    /// 被检单位名称
    /// </summary>
    [MaxLength(200)]
    public string OrganizationName { get; set; } = "";

    /// <summary>
    /// 作业项目
    /// </summary>
    [MaxLength(100)]
    public string WorkItem { get; set; } = "";
    /// <summary>
    /// 作业专业
    /// </summary>
    [MaxLength(100)]
    public string WorkSpecialty { get; set; } = "";

    /// <summary>
    /// 关键作业类型
    /// </summary>
    [MaxLength(32)]
    public string? WorkType { get; set; }

    /// <summary>
    /// 关键作业内容
    /// </summary>
    [MaxLength(100)]
    public string? WorkContent { get; set; }
    /// <summary>
    /// 作业风险等级
    /// </summary>
    [MaxLength(32)]
    public string? WorkRisk { get; set; }

    /// <summary>
    /// 位置区域
    /// </summary>
    [MaxLength(255)]
    public string Location { get; set; } = "";

    /// <summary>
    /// 违章人员ID
    /// </summary>
    [MaxLength(32)]
    public string? ViolationUserId { get; set; } = "";

    /// <summary>
    /// 违章人员姓名
    /// </summary>
    [MaxLength(255)]
    public string ViolationUserName { get; set; } = "";
    /// <summary>
    /// 违章人员单位名称
    /// </summary>
    [MaxLength(1000)]
    public string? ViolationUserDepart { get; set; } = "";

    /// <summary>
    /// 违章人员工号
    /// </summary>
    [MaxLength(100)]
    public string? Erp { get; set; }
    /// <summary>
    /// 违章岗位
    /// </summary>
    [MaxLength(32)]
    public string Position { get; set; } = "";

    /// <summary>
    /// 年龄
    /// </summary>
    [MaxLength(32)]
    public string Age { get; set; } = "";

    /// <summary>
    /// 工龄
    /// </summary>
    [MaxLength(32)]
    public string WorkYears { get; set; } = "";

    /// <summary>
    /// 用工性质
    /// </summary>
    [MaxLength(32)]
    public string EmployeeType { get; set; } = "";

    /// <summary>
    /// 违章扣分
    /// </summary>
    public float Score { get; set; }

    /// <summary>
    /// 罚款
    /// </summary>
    public float Fine { get; set; }

    /// <summary>
    /// 违章性质分类
    /// </summary>
    [MaxLength(32)]
    public string ViolationTypeCategory { get; set; } = "";

    /// <summary>
    /// 违章性质
    /// </summary>
    [MaxLength(32)]
    public string ViolationType { get; set; } = "";

    /// <summary>
    /// 违章条款
    /// </summary>
    [MaxLength(1000)]
    public string? ViolationClause { get; set; } = "";

    /// <summary>
    /// 违章描述
    /// </summary>
    [MaxLength(1000)]
    public string Description { get; set; } = "";

    /// <summary>
    /// 违章类别
    /// </summary>
    [MaxLength(100)]
    public string ViolationCategory { get; set; } = "";

    /// <summary>
    /// 对应要素体系
    /// </summary>
    [MaxLength(100)]
    public string HseElement { get; set; } = "";

    /// <summary>
    /// 对应安全沟通类型
    /// </summary>
    [MaxLength(100)]
    public string? ObserveComm { get; set; } = "";

    /// <summary>
    /// 原因分析
    /// </summary>
    [MaxLength(32)]
    public string CauseAnalysis { get; set; } = "";

    /// <summary>
    /// 归属直线部门
    /// </summary>
    [MaxLength(32)]
    public string DirectDepartment { get; set; } = "";

    /// <summary>
    /// 可能后果
    /// </summary>
    [MaxLength(32)]
    public string PotentialConsequence { get; set; } = "";

    /// <summary>
    /// 图片
    /// </summary>
    [MaxLength(1000)]
    public string? Pic { get; set; }

    [MaxLength(1000)]
    public string? ImageHash { get; set; }
    /// <summary>
    /// 违章类别ID
    /// </summary>
    [MaxLength(255)]
    public string? ViolationCateId { get; set; }
    /// <summary>
    /// 检查类型编码
    /// </summary>
    [MaxLength(255)]
    public string? CheckTypeCode { get; set; }
    /// <summary>
    /// 关键作业编码
    /// </summary>
    [MaxLength(255)]
    public string? KeyWorkCode { get; set; }
    /// <summary>
    /// 作业专业编码
    /// </summary>
    [MaxLength(255)]
    public string? WorkSpecialtyCode { get; set; }
    /// <summary>
    /// 违章性质编码
    /// </summary>
    [MaxLength(255)]
    public string? ViolationTypeCode { get; set; }
    /// <summary>
    /// 要素体系编码
    /// </summary>
    [MaxLength(255)]
    public string? HseCode { get; set; }
    /// <summary>
    /// 归属部门编码
    /// </summary>
    [MaxLength(255)]
    public string? DepartmentCode { get; set; }
    /// <summary>
    /// 原因分析编码
    /// </summary>
    [MaxLength(255)]
    public string? ClauseAnalysisCode { get; set; }
    /// <summary>
    /// 用工性质编码
    /// </summary>
    [MaxLength(255)]
    public string? EmployeeTypeCode { get; set; }
    /// <summary>
    /// 工龄编码
    /// </summary>
    [MaxLength(255)]
    public string? WorkYearsCode { get; set; }
    /// <summary>
    /// 年龄编码
    /// </summary>
    [MaxLength(255)]
    public string? AgeCode { get; set; }
    /// <summary>
    /// 可能后果编码
    /// </summary>
    [MaxLength(255)]
    public string? ConsequencesCode { get; set; }
    /// <summary>
    /// 违章岗位编码
    /// </summary>
    [MaxLength(255)]
    public string? PositionCode { get; set; }
    /// <summary>
    /// 位置区域编码
    /// </summary>
    [MaxLength(255)]
    public string? LocationCode { get; set; }

    /// <summary>
    /// 发包单位名
    /// </summary>
    [MaxLength(255)]
    public string? ContractingUnitName { get; set; }

    /// <summary>
    /// 发包单位ID
    /// </summary>
    [MaxLength(255)]
    public string? ContractingUnitId { get; set; }

    /// <summary>
    /// 文件
    /// </summary>
    public List<FileUploadItem>? Files { get; set; } = new List<FileUploadItem> ();

    public override void ConfigureMapper(Profile profile)
    {
        profile.CreateMap<QHSESysOverLappingViolation, QHSEOverLappingViolationModel>()
            .ForMember(d => d.QhseXyViolationId, options => options.MapFrom(s => s.QhseXyViolationId))
            .ForMember(d => d.UserId, options => options.MapFrom(s => s.UserId));

        profile.CreateMap<QHSEOverLappingViolationModel, QHSESysOverLappingViolation>()
            .ForMember(d => d.QhseXyViolationId, options => options.MapFrom(s => s.QhseXyViolationId))
            .ForMember(d => d.UserId, options => options.MapFrom(s => s.UserId));
    }
}
